#ifndef GRAPHICSCITY_H
#define GRAPHICSCITY_H

#include "city.h"
#include <QGraphicsItem>

class GraphicsCity : public QObject, public QGraphicsItem
{
    Q_OBJECT
public:

    GraphicsCity(City* city);
    static QRectF BOUNDINGRECT;  // 外接矩形
    static QColor LINECOLOR;     // 连线颜色

    City* pCity;


    bool hover;
    bool onPath;
    bool startEnd; // 是否为端点

    GraphicsCity* next;

    // QGraphicsItem interface
public:
    QRectF boundingRect() const{return BOUNDINGRECT;}
    QPointF center() const{return QPointF(BOUNDINGRECT.width()/2,BOUNDINGRECT.height()/2);}
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    int type() const{return UserType+1;}

protected:
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
    void mousePressEvent(QGraphicsSceneMouseEvent *event);

private:

signals:
    void pressed(City*);


};

#endif // GRAPHICSCITY_H
